#!/usr/bin/env node

const http = require('https'),
        url = require('url');

let city = process.argv[2] || '石家庄',
    addr = 'https://api.66mz8.com/api/weather.php?location=' + city;

let opt = url.parse(addr);
console.log(opt);
let opt1 = global.encodeURI(addr)

http.get(opt1, (res) => {
    let result = '';

    res.on('data', (data) => {
          //console.log(data);
          // console.log(data.toString('utf8'))
          result += data.toString('utf8');                });

    res.on('end', () => {
          let weather = JSON.parse(result);
          console.log(weather);             
    });
});

                       
